<?php
 require_once('Connections/mlu.php'); 
if (!isset($_SESSION)) {
  session_start();
}

?>

<html><head>

	<link rel="stylesheet" href="css/template.css" type="text/css" />
    <link rel="stylesheet" href="assets/css/styles.css" />
    <link rel="stylesheet" href="css/colorbox.css" />
    
	<link rel="stylesheet" href="assets/countdown/jquery.countdown.css" />

    
    <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>            
	<script type="text/javascript" src="js/jquery.colorbox.js"></script>

<?php 
 
$login=-1;

if (isset($_SESSION['Username']))    	//Se esiste una sessione!
{
	$login=1;
}
else									//Se non esiste la sessione
{
 if (isset($_POST['nick']))
 {
  $loginUsername=$_POST['nick'];
  $password=$_POST['passwd'];
  
  mysql_select_db($database_mlu, $mlu);
  
  $LoginRS__query="SELECT * FROM operatori WHERE nickname='$loginUsername' AND password='$password'";
   
  $LoginRS = mysql_query($LoginRS__query, $mlu) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser)
  {
	$_SESSION['Username'] = $loginUsername;
	$row_LoginRS = mysql_fetch_assoc($LoginRS);
	$_SESSION['grado']=$row_LoginRS['idgrado'];
	$login=1;											//Login=1 --> Accesso Consentito
  }
  else
  {
  	$login=0; 											//Login=0 --> Errore nell'accesso
  }
 }
} 

?>


	<script type="text/javascript">
	$(document).ready(function(){    
	    $('.menu a').click(function() { 
        var jrole = $(this).attr("href");
			$('#index').slideUp(1000,function(){$('#index').load(jrole,'',$(this).slideDown(1000))}); 
        return false; 
    });

<?php if ($_SESSION['grado']==4 || $_SESSION['grado']==1) {     //Questo if serve a caricare la pagina per l'apertura della cassa in vendita
       echo "var jrole = 'vendita/inscassa.php';";				
	   echo	"$('#index').load(jrole); ";
 }?>

});
	</script>

 <title>Meeting del libo usato 2012</title></head>
 <body class="page_bg">

<header>
        <div class="logo">
        <table cellpadding="0" cellspacing="0"><tr><td>

				<h1>Meeting del Libro usato 2012</h1>
                <h2> Dalla terra l'opera che cresce </h2>
                </td></tr></table>
		</div>

		<div class="top-menu">

			<div id="sgmenu">
   <?php  if (isset($_SESSION['grado'])) include ("upmenu.php"); 	 ?>
		  	</div>
            
		</div>

	</header>

<div id="header-img"></div>
	<section id="content">
		<div class="maincol_w_left">
			<div class="leftcol">
					  <?php  if (isset($_SESSION['grado'])) include ("leftmenu.php"); 	 ?>
            </div>
				<div class="cont">
                <div class="blog-featured"> 
				<div class="items-row cols-3 row-0"> 
                	<?php if ($login==0){		//login errato ?>
                    <h1>Nome utente o password errati</h1>
                    <?php } ?>
                	<div class="item column-1"> 
                        <?php
    						if ($login==-1 || $login==0)
								include ("login.php");    //inizializzazione della pagina
    						if ($login==1)
    						{  ?>
    							Ciao <?php echo $_SESSION['Username']; ?>
   					</div>
                    <div class="item column-1"> 
    						<div id="index">&nbsp;
							</div>
						</div>  
    						<?php } ?>
					</div>
                </div>
                </div>
				</div>
		<div class="clr"></div>

		</div>

		
</section>

	

<p style="text-align:center;"></p>
	



</body>


</html>